/**
 * Created by Ljh on 2016/12/7.
 */

//detail页面的控制器
angular.module('detailModule.controller', ['listModule.service'])
  .controller('detailController', ['$scope', '$stateParams', 'listFactory', '$location', function ($scope, $stateParams, listFactory, $location) {
    $scope.type = $stateParams.type;
    $scope.loading = true;

    $scope.getDetails = function () {
      listFactory.getData({}, 'subject/' + $scope.type, function (data) {
        $scope.loading = false;//关闭loading效果
        $scope.details = data;
        $scope.$apply();
      });
    };
    $scope.getDetails();

    /*//搜索功能函数
     $scope.page = {
     count:5,//每页显示数量
     start:0,//请求起始项
     current:1,//当前第几页
     totalCount:0,//总记录数
     totalPage:0//总页数
     };
     $scope.searchData = function (search,current) {
     $scope.loading = true;
     $scope.page.current = current || 1;
     $scope.page.search = search;//供点击下一页使用
     $scope.page.type = 'search';

     listFactory.searchData({q:search,count:5,start:(($scope.page.current-1)*$scope.page.count)},$scope.page.type,function (data) {
     $scope.moviesList = data;
     console.log(data);
     $scope.loading = false;
     $scope.page.totalCount = data.total;
     $scope.page.totalPage = Math.ceil( data.total/data.count );
     console.log($scope.type);
     $scope.$apply();
     });
     };
     $scope.$emit('listToApp',$scope.searchData);*/

  }])
/*.config(['$stateProvider','$urlRouterProvider', function ($stateProvider,$urlRouterProvider) {
 $stateProvider
 .state('search',{
 url: "/list/:type",
 templateUrl: './areas/list/list.html',
 controller: 'listController'
 })
 $urlRouterProvider.otherwise('/list/in_theaters');
 }])*/
